<?php 
namespace Home\Controller;
use Think\Controller;
class DetailsController extends BaseController
{
    function details()
    {
        $entryOb = M('wares_entry');
        $arr = $entryOb->join('son_images ON wares_entry.wares_id = son_images.wares_entry_id')->where("wares_entry.wares_id={$_GET['wares_id']}")->select();
        $this->assign('arr', $arr);
        $this->display();
    }

    function add_cart()
    {
        if ($_SESSION['user_name']) {
            $entryOb = M('wares_entry');
            $re = $entryOb->where("wares_id={$_GET['wares_id']}")->find();
            if ($re) {
                $data = array();
                $data = array(
                    "cart_wares_entry_name" => "{$re['wares_name']}",
                    "cart_wares_images" => "{$re['wares_images']}",
                    "cart_price" => "{$re['wares_newmoney']}",
                    "cart_user_name" => "{$_SESSION['user_name']}",
                    "num" => "{$_GET['num']}"
                );
                $cartOb = M('Cart');
                $cRe = $cartOb->data($data)->add();
                if ($cRe) {
                    $this->ajaxReturn(1);
                } else {
                    $this->ajaxReturn(0);
                }
            } else {
                $this->ajaxReturn(0);
            }
        } else {
            $this->ajaxReturn(0);
        }
    }
}